<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>百度换肤</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul li{
            list-style: none;
        }
        #skin{
            position: absolute;
            width: 100%;
            height: 100%;
            background-image: url('img/img1.jpg');
            background-attachment: fixed;
            background-repeat: no-repeat;
            object-fit: fill;
        }
        .skin-photo{
            position: relative;
            width: 100vw;
            height: 220px;
            z-index: 10;
        }
        .skin-photo ul{
            overflow: hidden;
            width: 1300px;
            margin: 0 auto;
            background-color: rgba(255, 255, 255, .5);
        }
        .skin-photo ul>li{
            float: left;
            cursor: pointer;
            height: 230px;
            margin: 10px 0 12px 10px;
        }
        .skin-photo ul>li>img{
            width: 200px;
            height: 211px;
        }
    </style>
</head>
<body>
    <div id="skin"></div>
    <div class="skin-photo">
        <ul>
            <li> <img src="img/img1.jpg" alt=""></li>
            <li> <img src="img/img2.jpg" alt=""></li>
            <li> <img src="img/img3.jpg" alt=""></li>
            <li> <img src="img/img4.jpg" alt=""></li>
            <li> <img src="img/img5.jpg" alt=""></li>
            <li> <img src="img/img6.jpg" alt=""></li>            
        </ul>
    </div>
   <script>
        var skin = document.getElementById('skin');
        var imgs = document.getElementsByTagName("img");
        for(var i = 0;i < imgs.length;i++){
            imgs[i].index = i + 1;
            imgs[i].onclick = function(){
            skin.style.backgroundImage = "url("+this.src+")";
        }
}
   </script>
</body>
</html>